<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* html,
        body {
            width: 100%;
            height: 100%;
        } */

        * {
            margin: 0px;
            padding: 0px;
        }

        .box-img {
            width: 100%;
            height: 250px;
            text-align: center;
            margin: 0px auto;
            display: none;
            overflow: hidden;
        }

        .box-img>img {
            width: 300px;
            height: 200px;
            object-fit: cover;
        }

        .box {
            display: block;
        }
    </style>
</head>

<body>
    <div class="box-img">
        <img src="1.jpg" alt="">
        <img src="2.jpg" alt="">
        <img src="3.jpg" alt="">
    </div>
    <button>换肤</button>

    <script>
        var btn = document.querySelector('button')
        var boxImg = document.querySelector('.box-img')
        var box = document.getElementsByClassName('box')
        btn.onclick = function () {
            boxImg.classList.toggle('box')
        }
        boxImg.onclick = function (e) {
            document.body.style.background = 'url(' + e.target.src + ') no-repeat 0 0/100% auto ';
            boxImg.classList.toggle('box')
        }
    </script>
</body>

</html>